/**
 * @Function 区域部门同步定时任务
 * @ProjectName credit-data-platform
 * @PackageName com.py.credit.controller
 * @FileName AreaDeptController.java
 * @Date 2018年6月5日下午2:10:01
 * @Author Min DongXv
 * @Copyright (c) 2018, 金电联行 All Rights Reserved.
 */
package com.py.credit.controller;

import com.py.credit.common.logs.ExceptionLogger;
import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.service.OfficeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Function 区域部门同步定时任务
 * @ClassName AreaDeptController
 * @Date 2018年6月5日 下午2:10:01
 * @Author Min DongXv
 */
@RestController
@RequestMapping(value = "/lhjcAreaDept")
public class LhjcAreaDeptController {

    @Autowired
    private OfficeService officeService;

    /**
     * @api {get} /syncAreaDept/syncArea.do 同步区域信息
     * @apiName syncArea
     * @apiVersion 0.0.1
     * @apiGroup 区域部门同步定时任务
     * @apiSuccess {String} code 状态码:1 成功 -1 失败
     * @apiSuccess {String} msg 错误信息
     * @apiSuccess {int} count 结果集数据量
     * @apiSuccess {String} data 结果集
     */
    @RequestMapping("/syncArea.do")
    public RestServiceResult<Object> syncArea() {
        RestServiceResult<Object> result = new RestServiceResult<Object>();
        try {
            officeService.syncArea();
            return result;
        } catch (Exception e) {
            result.setCode(RestServiceResult.CODE_UNKNOW);
            result.setMsg("同步联合奖惩区域数据异常！");
            ExceptionLogger.error("LhjcAreaDeptController#syncArea", "同步联合奖惩区域数据异常！ERROR:" + e.getMessage(), e);
            return result;
        }
    }

    /**
     * @api {get} /syncAreaDept/syncDept.do 同步部门数据
     * @apiName syncDept
     * @apiVersion 0.0.1
     * @apiGroup 区域部门同步定时任务
     * @apiSuccess {String} code 状态码:1 成功 -1 失败
     * @apiSuccess {String} msg 错误信息
     * @apiSuccess {int} count 结果集数据量
     * @apiSuccess {String} data 结果集
     */
    @RequestMapping("/syncDept.do")
    public RestServiceResult<Object> syncDept() {
        RestServiceResult<Object> result = new RestServiceResult<Object>();
        try {
            officeService.syncDept();
            return result;
        } catch (Exception e) {
            result.setCode(RestServiceResult.CODE_UNKNOW);
            result.setMsg("同步联合奖惩部门数据异常！");
            ExceptionLogger.error("LhjcAreaDeptController#syncDept", "同步联合奖惩部门数据异常！ERROR:" + e.getMessage(), e);
            return result;
        }
    }
}
